package com.zusmart.core.proxy.support;

import com.zusmart.core.proxy.ProxyHandler;
import com.zusmart.core.proxy.ProxyMethod;

public class ProxyChainForInterface extends AbstractProxyChain {

	public ProxyChainForInterface(Class<?> targetClass, Object targetInstance, Object[] targetArguments, ProxyMethod targetProxyMethod, ProxyHandler[] targetProxyHandlers) {
		super(targetClass, targetInstance, targetArguments, targetProxyMethod, targetProxyHandlers);
	}

	@Override
	protected Object doProxyChain(Object targetInstance, ProxyMethod proxyMethod) throws Throwable {
		Object result = null;
		for (int i = 0; i < this.targetProxyHandlers.length; i++) {
			result = this.targetProxyHandlers[i].getFactory().execute(this);
		}
		return result;
	}

}